<?php
/** @var EntidadController $this */
/** @var Entidad $model */
//$this->widget('booster.widgets.TbButton', array(
//'label' => Yii::t('AweCrud.app', 'Crear'),
////    <a title="Actualizar" href="/crm/entidad/update?id=1">
//'htmlOptions' => array('onclick' => Yii::app()->createUrl("crm/entidad/create"), 'class' => 'btn btn-default btn-sm', 'type' => "submit"),
//));
?>
<a title="Crear" href="<?php echo Yii::app()->createUrl("crm/entidad/create")?>"><button class="btn btn-default btn-sm"><i class="icon-pencil">Crear</i></button></a>
<div id="flashMsg"  class="flash-messages">

</div> 
<div class="panel panel-default">
    <div class="panel-heading">
        <h4 class="panel-title">
            <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
                <i class="fa fa-bold"></i><?php echo Yii::t('AweCrud.app', 'Manage') ?> <?php echo Entidad::label(2) ?> 
            </a>
        </h4>
    </div>
    <div id="collapseOne" class="panel-collapse collapse in">
        <div class="panel-body">
            <?php
            $this->widget('booster.widgets.TbGridView', array(
                'id' => 'entidad-grid',
//        'type' => 'striped bordered hover advance',table table-striped
                'type' => 'table table-striped',
                'dataProvider' => $model->activos()->searchEmpresasUsersAsignados(),
                'columns' => array(
                    array(
                        'name' => 'nombre',
                        'value' => 'CHtml::link($data->nombre, Yii::app()->createUrl("crm/entidad/view",array("id"=>$data->id)))',
                        'type' => 'raw',
                    ),
                    'razon_social',
                    'documento',
                    'website',
                    'raking',
                    'telefono',
                    array(
                        'name' => 'owner_id',
                        'value' => '$data->owner_id?Yii::app()->user->um->loadUserById($data->owner_id)->username:null',
                    ),
                    /*
                      'celular',
                      'email',
                      'max_entidad',
                      array(
                      'name' => 'estado',
                      'filter' => array('ACTIVO'=>'ACTIVO','INACTIVO'=>'INACTIVO',),
                      ),
                      'matriz',
                      array(
                      'name' => 'categoria_id',
                      'value' => 'isset($data->categoria) ? $data->categoria : null',
                      'filter' => CHtml::listData(Categoria::model()->findAll(), 'id', Categoria::representingColumn()),
                      ),
                      array(
                      'name' => 'industria_id',
                      'value' => 'isset($data->industria) ? $data->industria : null',
                      'filter' => CHtml::listData(Industria::model()->findAll(), 'id', Industria::representingColumn()),
                      ),
                      array(
                      'name' => 'entidad_id',
                      'value' => 'isset($data->direccion) ? $data->direccion : null',
                      'filter' => CHtml::listData(Direccion::model()->findAll(), 'id', Direccion::representingColumn()),
                      ),
                      'max_foto',
                      'owner_id',
                      'atencion',
                     */
                    array(
                        'class' => 'CButtonColumn',
                        'template' => '{update} {delete}',
                        'afterDelete' => 'function(link,success,data){ 
                    if(success) {
                         $("#flashMsg").empty();
                         $("#flashMsg").css("display","");
                         $("#flashMsg").html(data).animate({opacity: 1.0}, 5500).fadeOut("slow");
                    }
                    }',
                        'buttons' => array(
                            'update' => array(
                                'label' => '<button class="btn btn-primary"><i class="icon-pencil"></i></button>',
                                'options' => array('title' => 'Actualizar'),
                                'imageUrl' => false,
                            //'visible' => 'Util::checkAccess(array("action_incidenciaPrioridad_update"))'
                            ),
                            'delete' => array(
                                'label' => '<button class="btn btn-danger"><i class="icon-trash"></i></button>',
                                'options' => array('title' => 'Eliminar'),
                                'imageUrl' => false,
                            //'visible' => 'Util::checkAccess(array("action_incidenciaPrioridad_delete"))'
                            ),
                        ),
                        'htmlOptions' => array(
                            'width' => '80px'
                        )
                    ),
                ),
            ));
            ?>
        </div>
    </div>
</div>
